using WithRefsTest.DataModels;

namespace WithRefsTest.Client
{
	public class MyViewModel : ViewModelBase
	{
		private int _id;
		private Entity1 _result;

		public MyViewModel()
		{
			GetEntity1Command = new DelegateCommand<int>(GetEntity1, e => true);
		}

		public Entity1 Result
		{
			get { return _result; }
			set { SetFieldValue(ref _result, value, "Result"); }
		}

		public int Id
		{
			get { return _id; }
			set { SetFieldValue(ref _id, value, "Id"); }
		}

		public DelegateCommand<int> GetEntity1Command { get; private set; }

		private void GetEntity1(int parameter)
		{
			ProxyHelper.GetEntity1(parameter, OnGetEntity1);
		}

		private void OnGetEntity1(Entity1 res)
		{
			Result = res;
		}
	}
}